﻿<!DOCTYPE html>
<html ng-app="directiveApp">
<head>
    <title></title>
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <script src="scripts/angular.min.js"></script>
    <script type="text/javascript">
        angular.module("directiveApp", [])
            .directive("scopeDemo", function () {
                return {
                    template:
                    "<div class='panel-body'>Name: <input ng-model=name /></div>",
                }
            })
            .controller("scopeCtrl", function ($scope) {
            })
            .controller("secondCtrl", function ($scope) {
            });
    </script>
</head>
<body>
    <div class="panel panel-default">
        <!--
               两个directive各有各自的controller，因此各自维护自己的scope，互不干扰
           -->
        <div ng-controller="scopeCtrl" class="panel-body" scope-demo></div>
        <div ng-controller="secondCtrl" class="panel-body" scope-demo></div>
    </div>
</body>
</html>
